package com.freewater.parking.domain;

import com.freewater.parking.domain.blacklist.BlackList;
import com.freewater.parking.domain.blacklist.BlackListRepository;
import com.freewater.parking.domain.common.PlateNumber;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class MockBlackListRepository implements BlackListRepository {
    private Map<PlateNumber, BlackList> map = new HashMap<>();

    @Override
    public void save(BlackList blackList) {
        map.put(blackList.getPlateNumber(), blackList);
    }

    @Override
    public Optional<BlackList> findByPlateNumber(PlateNumber plateNumber) {
        return Optional.ofNullable(map.get(plateNumber));
    }

    @Override
    public void delete(BlackList blackList) {
        map.remove(blackList.getPlateNumber());
    }

    @Override
    public boolean existsById(PlateNumber plateNumber) {
        return findByPlateNumber(plateNumber).isPresent();
    }
}
